/**
 * ZeroTimeFormat.java 25.06.2006
 */
package org.dicr.util.text;

/**
 * Zero Time Format. Format time not from 1 Jan 1970, but from 1 Jan 0000 year
 * 
 * @author <A href='http://dicr.org'>Igor A Tarasov</A>
 * @version 060624
 */
public class ZeroTimeFormat {
	/**
     * Format milliseconds to format: Dd, HH:MM
     * 
     * @param millis milliseconds time
     * @return formatted string
     */
	public static String format(double millis) {
		if (millis < 0) throw new IllegalArgumentException("millis: " + millis);
		double rest = millis / 1000;
		StringBuilder sb = new StringBuilder();
		long hour = (long) (rest / 3600);
		if (hour > 0) rest %= hour * 3600;
		int min = (int) (rest / 60);
		if (min > 0) rest %= min * 60;
		int sec = (int) rest;
		sb.append(String.format("%02dч %02dм %02dс", Long.valueOf(hour), Integer.valueOf(min), Integer.valueOf(sec)));
		return sb.toString();
	}
}
